#pragma once
#include "services.pb.h"
#include "../Common/Common.h"
#include "../Common/Runable.h"

enum SessionStatus
{
	SS_LOGIN,
	SS_CHAR,
	SS_GAME
};

class SessionSerivce : public RPC::Service , public Runable
{
public:
	SessionSerivce(	uint32 account,const std::string& name) : m_account(account),m_name(name)
	{

	}

	virtual ~SessionSerivce(void)
	{
	}

	virtual void update(uint32 timeElapse)
	{
		Runable::update(timeElapse);
	}

// 	bool queueCallMethod(CallMethodData* dat)
// 	{
// 		boost::lock_guard<boost::mutex> g(m_mutex);
// 		m_callmethods.push_back(dat);
// 	}

	virtual void login(::google::protobuf::RpcController* controller,
						const ::RPC::LoginRequest* request,
						::RPC::CommonResponse* response,
						::google::protobuf::Closure* done);

	virtual void char_enum(::google::protobuf::RpcController* controller,
						const ::RPC::CharRequest* request,
						::RPC::CharResponse* response,
						::google::protobuf::Closure* done);

	virtual void char_create(::google::protobuf::RpcController* controller,
						const ::RPC::CharRequest* request,
						::RPC::CharResponse* response,
						::google::protobuf::Closure* done);

	virtual void char_delete(::google::protobuf::RpcController* controller,
						const ::RPC::CharRequest* request,
						::RPC::CharResponse* response,
						::google::protobuf::Closure* done);

	void closeSession()
	{

	}

	uint32 getAccount() const
	{
		return m_account;
	}

private:
	SessionStatus m_status;

	uint32 m_account;
	std::string m_name;

// 	boost::mutex m_mutex;
// 	std::vector<CallMethodData*> m_callmethods;
};

typedef boost::shared_ptr<SessionSerivce> SessionSerivcePtr;